import React, { Component } from 'react';
import {connect} from 'react-redux'
import {add} from '../actions/todos'

class Add extends Component{
	constructor(){
		super();
		this.add = this.add.bind(this);
	}
	add(){
		this.props.dispatch( add(this.refs.t.value,this.refs.c.value) );
		this.props.history.push("/");
	}
	render(){
		// console.log( this.props.dispatch )
		// console.log( add(1,2) )
		return (
			<div>
				<h3>Add</h3>
				<hr />
				<input type="text" ref = "t" />
				<textarea cols="30" rows="10" ref = "c"></textarea>
				<button onClick={this.add}>send</button>
			</div>
		)
	} 
}
export default connect()(Add)